{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas_datareader as pdr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "start = datetime.datetime(2006, 1, 1)\n",
    "end = datetime.datetime(2018, 1, 1)\n",
    "start_date_str = str(start.date())\n",
    "end_date_str = str(end.date())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "stocks = ['MMM', 'AXP', 'AAPL', 'BA', 'CAT', 'CVX', 'CSCO', 'KO', 'DIS', 'XOM', 'GE',\n",
    "          'GS', 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'MCD', 'MRK', 'MSFT', 'NKE', 'PFE',\n",
    "          'PG', 'TRV', 'UTX', 'UNH', 'VZ', 'WMT', 'GOOGL', 'AMZN', 'AABA']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "data/MMM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/AXP_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/AAPL_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/BA_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CAT_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CVX_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CSCO_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/KO_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/DIS_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/XOM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GS_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/HD_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/IBM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/INTC_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/JNJ_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/JPM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/MCD_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/MRK_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/MSFT_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/NKE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/PFE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/PG_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/TRV_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/UTX_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/UNH_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/VZ_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/V_2006-01-01_to_2018-01-01.csv\n",
      "(2465, 5)\n",
      "data/WMT_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GOOGL_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/AMZN_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/AABA_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n"
     ]
    }
   ],
   "source": [
    "for ticker in stocks:\n",
    "    file_name = 'data/' + ticker + '_' + start_date_str + '_to_' + end_date_str + '.csv'\n",
    "    print(file_name)\n",
    "    data = pdr.DataReader(ticker, 'google', start, end)\n",
    "    print(data.shape)\n",
    "    data.to_csv(file_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "data/MMM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/AXP_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/AAPL_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/BA_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CAT_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CVX_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/CSCO_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/KO_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/DIS_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/XOM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GS_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/HD_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/IBM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/INTC_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/JNJ_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/JPM_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/MCD_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/MRK_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/MSFT_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/NKE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/PFE_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/PG_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/TRV_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/UTX_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/UNH_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/VZ_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/WMT_2006-01-01_to_2018-01-01.csv\n",
      "(3020, 5)\n",
      "data/GOOGL_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/AMZN_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "data/AABA_2006-01-01_to_2018-01-01.csv\n",
      "(3019, 5)\n",
      "(93612, 6)\n"
     ]
    }
   ],
   "source": [
    "for (i, ticker) in enumerate(stocks):\n",
    "    file_name = 'data/' + ticker + '_' + start_date_str + '_to_' + end_date_str + '.csv'\n",
    "    print(file_name)\n",
    "    data = pd.read_csv(file_name, parse_dates=['Date'], index_col=['Date'])\n",
    "    print(data.shape)\n",
    "    data['Name'] = ticker\n",
    "    data.to_csv(file_name)\n",
    "    \n",
    "    if i == 0:\n",
    "        all_stocks = data\n",
    "    else:\n",
    "        all_stocks = all_stocks.append(data)\n",
    "        \n",
    "print(all_stocks.shape)\n",
    "all_stocks_file_name = 'data/all_stocks_' + start_date_str + '_to_' + end_date_str + '.csv'\n",
    "all_stocks.to_csv(all_stocks_file_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(93612, 6)\n"
     ]
    }
   ],
   "source": [
    "print(all_stocks.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_stocks = pd.read_csv(all_stocks_file_name, parse_dates=['Date'], index_col=['Date'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_stocks_2017 = all_stocks.loc['2017']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Volume</th>\n",
       "      <th>Name</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-01-03</th>\n",
       "      <td>178.83</td>\n",
       "      <td>180.00</td>\n",
       "      <td>177.22</td>\n",
       "      <td>178.05</td>\n",
       "      <td>2510055</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04</th>\n",
       "      <td>178.03</td>\n",
       "      <td>178.90</td>\n",
       "      <td>177.61</td>\n",
       "      <td>178.32</td>\n",
       "      <td>1541985</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05</th>\n",
       "      <td>178.26</td>\n",
       "      <td>179.14</td>\n",
       "      <td>176.89</td>\n",
       "      <td>177.71</td>\n",
       "      <td>1447848</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-06</th>\n",
       "      <td>177.29</td>\n",
       "      <td>178.60</td>\n",
       "      <td>175.80</td>\n",
       "      <td>178.23</td>\n",
       "      <td>1625049</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09</th>\n",
       "      <td>178.37</td>\n",
       "      <td>178.38</td>\n",
       "      <td>177.20</td>\n",
       "      <td>177.27</td>\n",
       "      <td>1622625</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-10</th>\n",
       "      <td>177.36</td>\n",
       "      <td>177.49</td>\n",
       "      <td>176.31</td>\n",
       "      <td>176.58</td>\n",
       "      <td>2030149</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-11</th>\n",
       "      <td>176.63</td>\n",
       "      <td>178.45</td>\n",
       "      <td>176.39</td>\n",
       "      <td>177.89</td>\n",
       "      <td>1579593</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-12</th>\n",
       "      <td>176.97</td>\n",
       "      <td>177.70</td>\n",
       "      <td>175.75</td>\n",
       "      <td>177.44</td>\n",
       "      <td>1321766</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-13</th>\n",
       "      <td>177.58</td>\n",
       "      <td>177.91</td>\n",
       "      <td>176.83</td>\n",
       "      <td>177.39</td>\n",
       "      <td>1265593</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-17</th>\n",
       "      <td>177.00</td>\n",
       "      <td>177.68</td>\n",
       "      <td>176.25</td>\n",
       "      <td>177.26</td>\n",
       "      <td>1557453</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-18</th>\n",
       "      <td>177.90</td>\n",
       "      <td>179.44</td>\n",
       "      <td>177.38</td>\n",
       "      <td>178.49</td>\n",
       "      <td>1804904</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-19</th>\n",
       "      <td>179.25</td>\n",
       "      <td>179.80</td>\n",
       "      <td>177.76</td>\n",
       "      <td>178.68</td>\n",
       "      <td>1464364</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-20</th>\n",
       "      <td>179.20</td>\n",
       "      <td>179.46</td>\n",
       "      <td>177.83</td>\n",
       "      <td>178.49</td>\n",
       "      <td>1761850</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-23</th>\n",
       "      <td>177.91</td>\n",
       "      <td>178.99</td>\n",
       "      <td>177.13</td>\n",
       "      <td>178.51</td>\n",
       "      <td>1986788</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-24</th>\n",
       "      <td>177.50</td>\n",
       "      <td>177.76</td>\n",
       "      <td>174.42</td>\n",
       "      <td>175.97</td>\n",
       "      <td>3473183</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-25</th>\n",
       "      <td>177.09</td>\n",
       "      <td>178.63</td>\n",
       "      <td>176.57</td>\n",
       "      <td>176.73</td>\n",
       "      <td>3462633</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-26</th>\n",
       "      <td>176.31</td>\n",
       "      <td>177.23</td>\n",
       "      <td>176.04</td>\n",
       "      <td>176.82</td>\n",
       "      <td>2235889</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-27</th>\n",
       "      <td>177.48</td>\n",
       "      <td>177.98</td>\n",
       "      <td>176.83</td>\n",
       "      <td>177.48</td>\n",
       "      <td>1623666</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-30</th>\n",
       "      <td>177.25</td>\n",
       "      <td>177.73</td>\n",
       "      <td>174.87</td>\n",
       "      <td>175.42</td>\n",
       "      <td>1823128</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-31</th>\n",
       "      <td>174.74</td>\n",
       "      <td>175.46</td>\n",
       "      <td>173.81</td>\n",
       "      <td>174.82</td>\n",
       "      <td>1845543</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-01</th>\n",
       "      <td>175.17</td>\n",
       "      <td>175.80</td>\n",
       "      <td>174.30</td>\n",
       "      <td>175.17</td>\n",
       "      <td>2272854</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-02</th>\n",
       "      <td>174.13</td>\n",
       "      <td>174.78</td>\n",
       "      <td>173.55</td>\n",
       "      <td>174.18</td>\n",
       "      <td>3106798</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-03</th>\n",
       "      <td>174.02</td>\n",
       "      <td>175.30</td>\n",
       "      <td>173.85</td>\n",
       "      <td>175.04</td>\n",
       "      <td>2820960</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-06</th>\n",
       "      <td>174.12</td>\n",
       "      <td>176.20</td>\n",
       "      <td>173.90</td>\n",
       "      <td>175.10</td>\n",
       "      <td>1622756</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-07</th>\n",
       "      <td>176.08</td>\n",
       "      <td>176.40</td>\n",
       "      <td>175.15</td>\n",
       "      <td>175.76</td>\n",
       "      <td>1247389</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-08</th>\n",
       "      <td>175.62</td>\n",
       "      <td>177.60</td>\n",
       "      <td>175.49</td>\n",
       "      <td>177.07</td>\n",
       "      <td>2145683</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-09</th>\n",
       "      <td>176.87</td>\n",
       "      <td>178.55</td>\n",
       "      <td>176.87</td>\n",
       "      <td>178.18</td>\n",
       "      <td>2009742</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-10</th>\n",
       "      <td>178.30</td>\n",
       "      <td>179.58</td>\n",
       "      <td>178.19</td>\n",
       "      <td>179.00</td>\n",
       "      <td>1392438</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-13</th>\n",
       "      <td>179.86</td>\n",
       "      <td>181.38</td>\n",
       "      <td>179.26</td>\n",
       "      <td>181.02</td>\n",
       "      <td>1929821</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-14</th>\n",
       "      <td>180.86</td>\n",
       "      <td>182.00</td>\n",
       "      <td>180.65</td>\n",
       "      <td>181.60</td>\n",
       "      <td>2036188</td>\n",
       "      <td>MMM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-16</th>\n",
       "      <td>69.80</td>\n",
       "      <td>71.22</td>\n",
       "      <td>69.80</td>\n",
       "      <td>70.75</td>\n",
       "      <td>7510504</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-17</th>\n",
       "      <td>70.81</td>\n",
       "      <td>71.37</td>\n",
       "      <td>70.74</td>\n",
       "      <td>71.02</td>\n",
       "      <td>14298554</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-20</th>\n",
       "      <td>71.60</td>\n",
       "      <td>72.53</td>\n",
       "      <td>71.43</td>\n",
       "      <td>71.95</td>\n",
       "      <td>14666339</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-21</th>\n",
       "      <td>72.66</td>\n",
       "      <td>73.14</td>\n",
       "      <td>72.31</td>\n",
       "      <td>72.85</td>\n",
       "      <td>9514310</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-22</th>\n",
       "      <td>73.02</td>\n",
       "      <td>73.25</td>\n",
       "      <td>72.46</td>\n",
       "      <td>72.60</td>\n",
       "      <td>6721660</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-24</th>\n",
       "      <td>72.47</td>\n",
       "      <td>73.18</td>\n",
       "      <td>72.31</td>\n",
       "      <td>72.93</td>\n",
       "      <td>3356343</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-27</th>\n",
       "      <td>72.82</td>\n",
       "      <td>73.12</td>\n",
       "      <td>71.92</td>\n",
       "      <td>72.07</td>\n",
       "      <td>7630057</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-28</th>\n",
       "      <td>72.25</td>\n",
       "      <td>72.48</td>\n",
       "      <td>71.49</td>\n",
       "      <td>71.98</td>\n",
       "      <td>11936842</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-29</th>\n",
       "      <td>71.61</td>\n",
       "      <td>71.70</td>\n",
       "      <td>68.51</td>\n",
       "      <td>70.36</td>\n",
       "      <td>15976247</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-30</th>\n",
       "      <td>70.31</td>\n",
       "      <td>70.84</td>\n",
       "      <td>69.37</td>\n",
       "      <td>70.06</td>\n",
       "      <td>19215640</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-01</th>\n",
       "      <td>69.80</td>\n",
       "      <td>71.25</td>\n",
       "      <td>69.47</td>\n",
       "      <td>70.10</td>\n",
       "      <td>19712943</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-04</th>\n",
       "      <td>71.06</td>\n",
       "      <td>71.34</td>\n",
       "      <td>68.16</td>\n",
       "      <td>68.31</td>\n",
       "      <td>15533597</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-05</th>\n",
       "      <td>67.10</td>\n",
       "      <td>69.38</td>\n",
       "      <td>66.62</td>\n",
       "      <td>68.13</td>\n",
       "      <td>11963099</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-06</th>\n",
       "      <td>67.78</td>\n",
       "      <td>69.62</td>\n",
       "      <td>67.36</td>\n",
       "      <td>69.41</td>\n",
       "      <td>11646582</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-07</th>\n",
       "      <td>69.75</td>\n",
       "      <td>70.64</td>\n",
       "      <td>69.48</td>\n",
       "      <td>70.22</td>\n",
       "      <td>7084564</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-08</th>\n",
       "      <td>71.00</td>\n",
       "      <td>71.63</td>\n",
       "      <td>70.82</td>\n",
       "      <td>71.25</td>\n",
       "      <td>7021125</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-11</th>\n",
       "      <td>71.70</td>\n",
       "      <td>72.09</td>\n",
       "      <td>71.15</td>\n",
       "      <td>71.53</td>\n",
       "      <td>7359312</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-12</th>\n",
       "      <td>71.07</td>\n",
       "      <td>71.15</td>\n",
       "      <td>69.55</td>\n",
       "      <td>69.77</td>\n",
       "      <td>11296188</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-13</th>\n",
       "      <td>69.80</td>\n",
       "      <td>71.76</td>\n",
       "      <td>69.69</td>\n",
       "      <td>71.24</td>\n",
       "      <td>17321301</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-14</th>\n",
       "      <td>70.60</td>\n",
       "      <td>70.62</td>\n",
       "      <td>68.84</td>\n",
       "      <td>69.23</td>\n",
       "      <td>17077065</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-15</th>\n",
       "      <td>69.35</td>\n",
       "      <td>70.54</td>\n",
       "      <td>68.66</td>\n",
       "      <td>70.29</td>\n",
       "      <td>19517623</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-18</th>\n",
       "      <td>70.54</td>\n",
       "      <td>70.74</td>\n",
       "      <td>69.95</td>\n",
       "      <td>70.14</td>\n",
       "      <td>6776982</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-19</th>\n",
       "      <td>69.70</td>\n",
       "      <td>70.36</td>\n",
       "      <td>69.38</td>\n",
       "      <td>70.21</td>\n",
       "      <td>14654994</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-20</th>\n",
       "      <td>70.60</td>\n",
       "      <td>71.05</td>\n",
       "      <td>70.17</td>\n",
       "      <td>70.90</td>\n",
       "      <td>12888149</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-21</th>\n",
       "      <td>71.00</td>\n",
       "      <td>72.17</td>\n",
       "      <td>70.88</td>\n",
       "      <td>71.59</td>\n",
       "      <td>9682733</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-22</th>\n",
       "      <td>71.42</td>\n",
       "      <td>71.87</td>\n",
       "      <td>71.22</td>\n",
       "      <td>71.58</td>\n",
       "      <td>10979165</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-26</th>\n",
       "      <td>70.94</td>\n",
       "      <td>71.39</td>\n",
       "      <td>69.63</td>\n",
       "      <td>69.86</td>\n",
       "      <td>8542802</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-27</th>\n",
       "      <td>69.77</td>\n",
       "      <td>70.49</td>\n",
       "      <td>69.69</td>\n",
       "      <td>70.06</td>\n",
       "      <td>6345124</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-28</th>\n",
       "      <td>70.12</td>\n",
       "      <td>70.32</td>\n",
       "      <td>69.51</td>\n",
       "      <td>69.82</td>\n",
       "      <td>7556877</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29</th>\n",
       "      <td>69.79</td>\n",
       "      <td>70.13</td>\n",
       "      <td>69.43</td>\n",
       "      <td>69.85</td>\n",
       "      <td>6613070</td>\n",
       "      <td>AABA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7781 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              Open    High     Low   Close    Volume  Name\n",
       "Date                                                      \n",
       "2017-01-03  178.83  180.00  177.22  178.05   2510055   MMM\n",
       "2017-01-04  178.03  178.90  177.61  178.32   1541985   MMM\n",
       "2017-01-05  178.26  179.14  176.89  177.71   1447848   MMM\n",
       "2017-01-06  177.29  178.60  175.80  178.23   1625049   MMM\n",
       "2017-01-09  178.37  178.38  177.20  177.27   1622625   MMM\n",
       "2017-01-10  177.36  177.49  176.31  176.58   2030149   MMM\n",
       "2017-01-11  176.63  178.45  176.39  177.89   1579593   MMM\n",
       "2017-01-12  176.97  177.70  175.75  177.44   1321766   MMM\n",
       "2017-01-13  177.58  177.91  176.83  177.39   1265593   MMM\n",
       "2017-01-17  177.00  177.68  176.25  177.26   1557453   MMM\n",
       "2017-01-18  177.90  179.44  177.38  178.49   1804904   MMM\n",
       "2017-01-19  179.25  179.80  177.76  178.68   1464364   MMM\n",
       "2017-01-20  179.20  179.46  177.83  178.49   1761850   MMM\n",
       "2017-01-23  177.91  178.99  177.13  178.51   1986788   MMM\n",
       "2017-01-24  177.50  177.76  174.42  175.97   3473183   MMM\n",
       "2017-01-25  177.09  178.63  176.57  176.73   3462633   MMM\n",
       "2017-01-26  176.31  177.23  176.04  176.82   2235889   MMM\n",
       "2017-01-27  177.48  177.98  176.83  177.48   1623666   MMM\n",
       "2017-01-30  177.25  177.73  174.87  175.42   1823128   MMM\n",
       "2017-01-31  174.74  175.46  173.81  174.82   1845543   MMM\n",
       "2017-02-01  175.17  175.80  174.30  175.17   2272854   MMM\n",
       "2017-02-02  174.13  174.78  173.55  174.18   3106798   MMM\n",
       "2017-02-03  174.02  175.30  173.85  175.04   2820960   MMM\n",
       "2017-02-06  174.12  176.20  173.90  175.10   1622756   MMM\n",
       "2017-02-07  176.08  176.40  175.15  175.76   1247389   MMM\n",
       "2017-02-08  175.62  177.60  175.49  177.07   2145683   MMM\n",
       "2017-02-09  176.87  178.55  176.87  178.18   2009742   MMM\n",
       "2017-02-10  178.30  179.58  178.19  179.00   1392438   MMM\n",
       "2017-02-13  179.86  181.38  179.26  181.02   1929821   MMM\n",
       "2017-02-14  180.86  182.00  180.65  181.60   2036188   MMM\n",
       "...            ...     ...     ...     ...       ...   ...\n",
       "2017-11-16   69.80   71.22   69.80   70.75   7510504  AABA\n",
       "2017-11-17   70.81   71.37   70.74   71.02  14298554  AABA\n",
       "2017-11-20   71.60   72.53   71.43   71.95  14666339  AABA\n",
       "2017-11-21   72.66   73.14   72.31   72.85   9514310  AABA\n",
       "2017-11-22   73.02   73.25   72.46   72.60   6721660  AABA\n",
       "2017-11-24   72.47   73.18   72.31   72.93   3356343  AABA\n",
       "2017-11-27   72.82   73.12   71.92   72.07   7630057  AABA\n",
       "2017-11-28   72.25   72.48   71.49   71.98  11936842  AABA\n",
       "2017-11-29   71.61   71.70   68.51   70.36  15976247  AABA\n",
       "2017-11-30   70.31   70.84   69.37   70.06  19215640  AABA\n",
       "2017-12-01   69.80   71.25   69.47   70.10  19712943  AABA\n",
       "2017-12-04   71.06   71.34   68.16   68.31  15533597  AABA\n",
       "2017-12-05   67.10   69.38   66.62   68.13  11963099  AABA\n",
       "2017-12-06   67.78   69.62   67.36   69.41  11646582  AABA\n",
       "2017-12-07   69.75   70.64   69.48   70.22   7084564  AABA\n",
       "2017-12-08   71.00   71.63   70.82   71.25   7021125  AABA\n",
       "2017-12-11   71.70   72.09   71.15   71.53   7359312  AABA\n",
       "2017-12-12   71.07   71.15   69.55   69.77  11296188  AABA\n",
       "2017-12-13   69.80   71.76   69.69   71.24  17321301  AABA\n",
       "2017-12-14   70.60   70.62   68.84   69.23  17077065  AABA\n",
       "2017-12-15   69.35   70.54   68.66   70.29  19517623  AABA\n",
       "2017-12-18   70.54   70.74   69.95   70.14   6776982  AABA\n",
       "2017-12-19   69.70   70.36   69.38   70.21  14654994  AABA\n",
       "2017-12-20   70.60   71.05   70.17   70.90  12888149  AABA\n",
       "2017-12-21   71.00   72.17   70.88   71.59   9682733  AABA\n",
       "2017-12-22   71.42   71.87   71.22   71.58  10979165  AABA\n",
       "2017-12-26   70.94   71.39   69.63   69.86   8542802  AABA\n",
       "2017-12-27   69.77   70.49   69.69   70.06   6345124  AABA\n",
       "2017-12-28   70.12   70.32   69.51   69.82   7556877  AABA\n",
       "2017-12-29   69.79   70.13   69.43   69.85   6613070  AABA\n",
       "\n",
       "[7781 rows x 6 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_stocks_2017"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_stocks_2017_file_name = 'data/all_stocks_2017-01-01_to_2018-01-01.csv'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_stocks_2017.to_csv(all_stocks_2017_file_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
